﻿using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Drawing.Design;
using System.Windows.Forms;
using HML.Design;

namespace HML
{
    /// <summary>
    /// TabControlPlus下拉面板配置
    /// </summary>
    [TypeConverter(typeof(PropertyOrderConverter))]
    public class TabControlPlusPickerStyle
    {
        #region 属性

        private Color borderColor = Color.Silver;
        /// <summary>
        /// 下拉框边框颜色
        /// </summary>
        [Description(" 下拉框边框颜色")]
        [PropertyOrder(-60)]
        [DefaultValue(typeof(Color), "Silver")]
        public Color BorderColor
        {
            get { return this.borderColor; }
            set
            {
                if (this.borderColor == value)
                    return;

                this.borderColor = value;
            }
        }

        private Size maxSize = new Size(400, 600);
        /// <summary>
        /// 下拉框最大Size
        /// </summary>
        [Description("下拉框最大Size")]
        [PropertyOrder(-58)]
        [DefaultValue(typeof(Size), "400,600")]
        public Size MaxSize
        {
            get { return this.maxSize; }
            set
            {
                if (this.maxSize == value || value.Width < 0 || value.Height < 0)
                    return;

                this.maxSize = value;
            }
        }

        #region 下拉框选项

        private bool itemIcoVisible = false;
        /// <summary>
        /// 是否显示选项图标
        /// </summary>
        [Description("是否显示选项图标")]
        [PropertyOrder(-54)]
        [DefaultValue(false)]
        public bool ItemIcoVisible
        {
            get { return this.itemIcoVisible; }
            set
            {
                if (this.itemIcoVisible == value)
                    return;

                this.itemIcoVisible = value;
            }
        }

        private int itemHeight = 24;
        /// <summary>
        /// 下拉框选项高度
        /// </summary>
        [Description("下拉框选项高度")]
        [PropertyOrder(-52)]
        [DefaultValue(24)]
        public int ItemHeight
        {
            get { return this.itemHeight; }
            set
            {
                if (this.itemHeight == value || value < 0)
                    return;

                this.itemHeight = value;
            }
        }

        private LRPadding itemLRPadding = new LRPadding(3, 3);
        /// <summary>
        /// 下拉框选项左右内边距
        /// </summary>
        [Description("下拉框选项左右内边距")]
        [PropertyOrder(-51)]
        [DefaultValue(typeof(LRPadding), "3, 3")]
        public LRPadding ItemLRPadding
        {
            get { return this.itemLRPadding; }
            set
            {
                if (value.Left < 0)
                    value.Left = 0;
                if (value.Right < 0)
                    value.Right = 0;
                if (this.itemLRPadding == value)
                    return;

                this.itemLRPadding = value;
            }
        }

        private Font itemFont = (Font)Control.DefaultFont.Clone();
        /// <summary>
        /// 下拉框选项字体
        /// </summary>
        [Description("下拉框选项字体")]
        [PropertyOrder(-50)]
        [DefaultValue(typeof(Font), "宋体,9pt")]
        public Font ItemFont
        {
            get { return this.itemFont; }
            set
            {
                if (this.itemFont == value)
                    return;

                this.itemFont = value;
            }
        }

        private Color itemBackNormalColor = Color.White;
        /// <summary>
        /// 下拉框选项背景颜色（正常）
        /// </summary>
        [Description(" 下拉框选项背景颜色（正常）")]
        [PropertyOrder(-48)]
        [DefaultValue(typeof(Color), "White")]
        public Color ItemBackNormalColor
        {
            get { return this.itemBackNormalColor; }
            set
            {
                if (this.itemBackNormalColor == value)
                    return;

                this.itemBackNormalColor = value;
            }
        }

        private Color itemTextNormalColor = Color.Gray;
        /// <summary>
        /// 下拉框选项文本颜色（正常）
        /// </summary>
        [Description(" 下拉框选项文本颜色（正常）")]
        [PropertyOrder(-46)]
        [DefaultValue(typeof(Color), "Gray")]
        public Color ItemTextNormalColor
        {
            get { return this.itemTextNormalColor; }
            set
            {
                if (this.itemTextNormalColor == value)
                    return;

                this.itemTextNormalColor = value;
            }
        }

        private Color itemBackEnterColor = Color.FromArgb(130, 178, 178);
        /// <summary>
        /// 下拉框选项背景颜色（鼠标进入）
        /// </summary>
        [Description(" 下拉框选项背景颜色（鼠标进入）")]
        [PropertyOrder(-44)]
        [DefaultValue(typeof(Color), "130, 178, 178")]
        public Color ItemBackEnterColor
        {
            get { return this.itemBackEnterColor; }
            set
            {
                if (this.itemBackEnterColor == value)
                    return;

                this.itemBackEnterColor = value;
            }
        }

        private Color itemTextEnterColor = Color.White;
        /// <summary>
        /// 下拉框选项文本颜色（鼠标进入）
        /// </summary>
        [Description(" 下拉框选项文本颜色（鼠标进入）")]
        [PropertyOrder(-42)]
        [DefaultValue(typeof(Color), "White")]
        public Color ItemTextEnterColor
        {
            get { return this.itemTextEnterColor; }
            set
            {
                if (this.itemTextEnterColor == value)
                    return;

                this.itemTextEnterColor = value;
            }
        }

        private TabControlPlusPickerItemSplitterStyles itemSplitterStyle = TabControlPlusPickerItemSplitterStyles.GradualLine;
        /// <summary>
        /// 下拉框选项分割线风格
        /// </summary>
        [Description("下拉框选项分割线风格")]
        [PropertyOrder(-40)]
        [DefaultValue(TabControlPlusPickerItemSplitterStyles.GradualLine)]
        public TabControlPlusPickerItemSplitterStyles ItemSplitterStyle
        {
            get { return this.itemSplitterStyle; }
            set
            {
                if (this.itemSplitterStyle == value)
                    return;

                this.itemSplitterStyle = value;
            }
        }

        private Color itemSplitterColor = Color.FromArgb(224, 224, 224);
        /// <summary>
        /// 下拉框选项分割线颜色
        /// </summary>
        [Description(" 下拉框选项分割线颜色")]
        [PropertyOrder(-38)]
        [DefaultValue(typeof(Color), "224, 224, 224")]
        public Color ItemSplitterColor
        {
            get { return this.itemSplitterColor; }
            set
            {
                if (this.itemSplitterColor == value)
                    return;

                this.itemSplitterColor = value;
            }
        }

        #endregion

        #region  下拉框滚动条

        private int scrollBarThickness = 10;
        /// <summary>
        /// 下拉框滚动条滑条厚度
        /// </summary>
        [Description("下拉框滚动条滑条厚度")]
        [PropertyOrder(-34)]
        [DefaultValue(10)]
        public int ScrollBarThickness
        {
            get { return this.scrollBarThickness; }
            set
            {
                if (this.scrollBarThickness == value || value < 0)
                    return;

                this.scrollBarThickness = value;
            }
        }

        private Color scrollBarBackColor = Color.FromArgb(68, 128, 128, 128);
        /// <summary>
        /// 下拉框滚动条滑条背景颜色
        /// </summary>
        [Description("下拉框滚动条滑条背景颜色")]
        [PropertyOrder(-32)]
        [DefaultValue(typeof(Color), "68, 128, 128, 128")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color ScrollBarBackColor
        {
            get { return this.scrollBarBackColor; }
            set
            {
                if (this.scrollBarBackColor == value)
                    return;

                this.scrollBarBackColor = value;
            }
        }


        private int scrollSlideMinSize = 26;
        /// <summary>
        /// 下拉框滚动条滑块最小高度
        /// </summary>
        [Description("下拉框滚动条滑块最小高度")]
        [PropertyOrder(-30)]
        [DefaultValue(26)]
        public int ScrollSlideMinSize
        {
            get { return this.scrollSlideMinSize; }
            set
            {
                if (this.scrollSlideMinSize == value || value < 1)
                    return;

                this.scrollSlideMinSize = value;
            }
        }

        private Color scrollSlideBackNormalColor = Color.FromArgb(120, 64, 64, 64);
        /// <summary>
        /// 下拉框滚动条滑块背景颜色（正常）
        /// </summary>
        [Description("下拉框滚动条滑块背景颜色（正常）")]
        [PropertyOrder(-28)]
        [DefaultValue(typeof(Color), "120, 64, 64, 64")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color ScrollSlideBackNormalColor
        {
            get { return this.scrollSlideBackNormalColor; }
            set
            {
                if (this.scrollSlideBackNormalColor == value)
                    return;

                this.scrollSlideBackNormalColor = value;
            }
        }

        private Color scrollSlideBackEnterColor = Color.FromArgb(160, 64, 64, 64);
        /// <summary>
        /// 下拉框滚动条滑块背景颜色（鼠标进入）
        /// </summary>
        [Description("下拉框滚动条滑块背景颜色（鼠标进入）")]
        [PropertyOrder(-26)]
        [DefaultValue(typeof(Color), "160,64, 64, 64")]
        [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
        public Color ScrollSlideBackEnterColor
        {
            get { return this.scrollSlideBackEnterColor; }
            set
            {
                if (this.scrollSlideBackEnterColor == value)
                    return;

                this.scrollSlideBackEnterColor = value;
            }
        }

        #endregion

        #region 临时存储

        /// <summary>
        /// 下拉框滚动条滑条Rect
        /// </summary>
        [Description("下拉框滚动条滑条Rect")]
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Rectangle ScrollBar_Rect { get; set; }

        /// <summary>
        /// 下拉框滚动条滑块rect
        /// </summary>
        [Description("下拉框滚动条滑块rect")]
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public RectangleF ScrollSlide_Rect { get; set; }

        #endregion

        #endregion
    }

}
